package cn.ac.iie.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Configuration
public class ApplicationConfig {

  @Value("${black-list.hive:}")
  private String[] hiveBlacklist;

  @Value("${black-list.kafka.recv:}")
  private String[] kafkaRecvBlacklist;

  @Value("${black-list.kafka.sent:}")
  private String[] kafkaSentBlackList;

  public List<String[]> getHiveBlacklist() {
    List<String[]> result = new ArrayList<>();
    if (hiveBlacklist != null && hiveBlacklist.length > 0) {
      result = Arrays.stream(hiveBlacklist).map(item -> item.split("\\.")).collect(Collectors.toList());
    }
    return result;
  }

  public List<String[]> getKafkaRecvBlacklist() {
    List<String[]> result = new ArrayList<>();
    if (kafkaRecvBlacklist != null && kafkaRecvBlacklist.length > 0) {
      result = Arrays.stream(kafkaRecvBlacklist).map(item -> item.split("\\.")).collect(Collectors.toList());
    }
    return result;
  }

  public List<String[]> getKafkaSentBlackList() {
    List<String[]> result = new ArrayList<>();
    if (kafkaSentBlackList != null && kafkaSentBlackList.length > 0) {
      result = Arrays.stream(kafkaSentBlackList).map(item -> item.split("\\.")).collect(Collectors.toList());
    }
    return result;
  }
}
